﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:ctrl="clr-namespace:Waf.InformationManager.Common.Presentation.Controls">

    <Style TargetType="{x:Type ctrl:SearchBox}">
        <Setter Property="HintText" Value="_Search"/>
        <Setter Property="Margin" Value="2"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ctrl:SearchBox}">
                    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid>
                            <Label Content="{TemplateBinding HintText}" Target="{Binding ElementName=searchBox}" Padding="0" Margin="5,3">
                                <Label.Style>
                                    <Style TargetType="Label">
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding Text, ElementName=searchBox}" Value="">
                                                <Setter Property="Foreground" Value="Gray"/>
                                            </DataTrigger>
                                        </Style.Triggers>
                                        <Setter Property="Foreground" Value="Transparent"/>
                                    </Style>
                                </Label.Style>
                            </Label>
                            <TextBox x:Name="searchBox" Text="{Binding SearchText, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}" 
                                     Background="Transparent" HorizontalAlignment="Stretch" Margin="0"/>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>